import { _decorator, Component, Node, Button, director, Vec3, Sprite, instantiate, Prefab } from "cc";
import GameConfig from "../constant/GameConfig";
import GameCtrl from "../model/GameCtrl";
import LoaderUtils from "../utils/LoaderUtils";
import PoolUtils from "../utils/PoolUtils";
import UIUtils from "../utils/UIUtils";
import UIPoker from "../view/poker/UIPoker";
const { ccclass, property } = _decorator;
@ccclass("SplashScene")
export class SplashScene extends Component {
  @property(Prefab)
  pokerPerfab: Prefab;
  @property(Button)
  btnStart: Button = null;
  @property(Node)
  sp1: Node = null;
  @property(Node)
  sp2: Node = null;
  @property(Sprite)
  img1: Sprite = null;
  @property(Node)
  img2: Node = null;
  onLoad() {
    //
  }
  start() {
    this.createUIPoker();
    this.btnStart.node.on("click", this.onStart.bind(this));
    GameCtrl.ins.creatrAI();
  }
  onStart(): void {
    director.loadScene("GameScene", () => {});
  }
  /**
   * 创建扑克实例
   * 先从池子里要
   */
  private createUIPoker(): void {
    for (let i = 0; i < GameConfig.POKER_NUM; i++) {
      let pokerNode: Node = instantiate(this.pokerPerfab);
      PoolUtils.ins.uiPoker.put(pokerNode);
    }
  }

  onDestroy(): void {}
}
